package digital.store.tutorial.springmvc.model;



import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.ManyToOne;

import javax.validation.constraints.NotNull;
import javax.persistence.*;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

import digital.store.tutorial.springmvc.model.Order;

@Entity
public class Product {
	 
	@Id 
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	@NotNull
    private String name;
	
	private String shortdescription;
	
	@NotNull
	private String color;
	
	private String model;
	
	private String status;
	

	private float promotionprice;
	
	@NotNull
	private float price;
	
	private String fulldescription;
	
	private String img1;
	
	private String img2;
	
	private String img3;
	
	@Transient
	private CommonsMultipartFile imgData1;
	
	@Transient
	private CommonsMultipartFile imgData2;
	
	@Transient
	private CommonsMultipartFile imgData3;
	
	@ManyToOne (fetch = FetchType.LAZY)
	private Category category;
	
	
	@ManyToMany (fetch = FetchType.LAZY,cascade = CascadeType.PERSIST)
	@JoinTable(name ="product_order", 
				joinColumns = @JoinColumn(name="product_id"),
				inverseJoinColumns =@JoinColumn(name="order_id"))
	private Collection<Order> orders;
	
	
	
	@NotNull
	private int stock;
	
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}



	
	public String getShortdescription() {
		return shortdescription;
	}

	public void setShortdescription(String shortdescription) {
		this.shortdescription = shortdescription;
	}

	public String getColor() {
		return color;
	}

	public void setColor(String color) {
		this.color = color;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}

	public float getPromotionprice() {
		return promotionprice;
	}

	public void setPromotionprice(float promotionprice) {
		this.promotionprice = promotionprice;
	}

	public String getImg1() {
		return img1;
	}

	public void setImg1(String img1) {
		this.img1 = img1;
	}

	public String getImg2() {
		return img2;
	}

	public void setImg2(String img2) {
		this.img2 = img2;
	}

	public String getImg3() {
		return img3;
	}

	public void setImg3(String img3) {
		this.img3 = img3;
	}

	public CommonsMultipartFile getImgData1() {
		return imgData1;
	}

	public void setImgData1(CommonsMultipartFile imgData1) {
		this.imgData1 = imgData1;
	}

	public CommonsMultipartFile getImgData2() {
		return imgData2;
	}

	public void setImgData2(CommonsMultipartFile imgData2) {
		this.imgData2 = imgData2;
	}

	public CommonsMultipartFile getImgData3() {
		return imgData3;
	}

	public void setImgData3(CommonsMultipartFile imgData3) {
		this.imgData3 = imgData3;
	}

	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	

	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	
	public float getPrice() {
		return price;
	}
	
	public void setPrice(float price) {
		this.price = price;
	}

	public Collection<Order> getOrders() {
		return orders;
	}

	public void setOrders(Collection<Order> orders) {
		this.orders = orders;
	}
	
	public int getStock() {
		return stock;
	}

	public void setStock(int stock) {
		this.stock = stock;
	}


	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public String getFulldescription() {
		return fulldescription;
	}

	public void setFulldescription(String fulldescription) {
		this.fulldescription = fulldescription;
	}
	
	
	
}
